package com.fengmoxi.ctv.manage;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import java.util.Objects;

public class AppInstalledReceiver extends BroadcastReceiver {
    private static final String TAG = AppInstalledReceiver.class.getSimpleName();

    @Override
    public void onReceive(Context context, Intent intent) {
        if (Objects.equals(intent.getAction(), Intent.ACTION_PACKAGE_ADDED)) {
            String packageName = intent.getDataString();
            Log.i(TAG, "App Install: " + packageName);
        }

        if (intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)) {
            String packageName = intent.getDataString();
            Log.i(TAG, "App Uninstall: " + packageName);
        }

        if (intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED)) {
            String packageName = intent.getDataString();
            Log.i(TAG, "App Reinstall: " + packageName);
        }
    }
}